<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/js/erp/ajaxSessionTimeOut.js"></script>
<script type="text/javascript">
$(function() {
    parent.$.messager.progress('close');
    $('#form').form({
        url : contextPath+"/role/addRole.action",
        onSubmit : function() {
            parent.$.messager.progress({
                title : '提示',
                text : '数据处理中，请稍后....'
            });
            //检查Form参数合法性,返回false不提交
           if(!checkForm()){
               parent.$.messager.progress('close');
                return false;
            }
        },
        success : function(data) {
            parent.$.messager.progress('close');
            data = JSON.parse(data);
            if(data && "success" == data.result){
                parent.$.messager.alert('提示信息', data.msg, 'info');
                parent.$.modalDialog.handler.dialog('close');
                parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
            } else {
                parent.$.messager.alert('错误', data.msg, 'error');
            }
        }
    });
});

function checkForm(){
	var isValid = true;
    var name = $("#form").find("[name='name']").validatebox({
        required: true,
        validType:['length[1,100]']
    });
    isValid = isValid && name.validatebox('isValid');
    return isValid;
}
</script>
<div id="add-edit-dialog">  
    <div class="p5">
        <form id="form" name="addEditRoleForm" action="" method="post" class="mb5">
            <input id="roleId" name="id" type="hidden" value=""/>
            <ul class="fn-clear" style="margin-left: 40px;"> 
                <li class=""> 
                    <label for="name" class="fl pt3 pl15">名称：</label> 
                    <input name="name" class="span2" type="text" value=""/>
                </li>
                <li class="">
                   <label for="description" class="fl pt3" style="margin-left: -12px;">描述信息：</label> 
                   <textarea name="description" class="" style="height: 80px;overflow: auto;line-height: 18px;width: 395px;"></textarea>
                </li>
            </ul>
            <div class="fn-clear"></div>
        </form>
    </div>
</div> 